Skip to content

feat(Overlay): call onBeforeDismiss before an overlay is dismissed - #1371

Merged
mstijak merged 1 commit into
masterfrom
feat/overlay-before-dismiss
Nov 24, 2026
Merged

mstijak merged 1 commit into
masterfrom
feat/overlay-before-dismiss

Conversation

@mstijak

@mstijak mstijak commented Nov 24, 2026

Copy link
Copy Markdown
Member

Overlays such as Window and Dropdown call onBeforeDismiss(instance, component) before they are dismissed, e.g. with Escape, the close button or the function returned by open, and stay open if it returns false. It can also name a controller method. Setting visible to false closes the overlay without calling it.

Related to #1092.

Background

onBeforeDismiss was added to OverlayConfig in the TypeScript conversion of the overlays (5c88bfb), but nothing called it: the name was only used internally, for the onBeforeDismiss method of the overlay component that runs overlayWillDismiss. The JavaScript versions and their .d.ts files did not have the option, so it never worked. overlayWillDismiss(instance, component) remains as before.

Implementation

OverlayComponent.onBeforeDismiss, which runs before every dismissal of a mounted overlay, now invokes the widget's onBeforeDismiss with instance.invoke, like the other overlay callbacks, before overlayWillDismiss. The type of the option is now string | ((instance, component) => boolean | void).

Docs

onBeforeDismiss is added to the configuration of Window and Overlay.

Tests

New in Window.browser.spec.tsx, which fail without the change:

  • "keeps the window open while it returns false": Escape and the close button are blocked; the window closes once it allows it.
  • "calls a controller method given by name".
  • "is invoked by the dismiss function of a window opened with open".

Overlays such as Window and Dropdown call onBeforeDismiss(instance, component) before they are dismissed, e.g. with Escape, the close button or the function returned by open, and stay open if it returns false. It can also name a controller method. The option was declared in the types, but it was never called. Setting visible to false closes the overlay without calling it.
@mstijak
mstijak merged commit f46c384 into master Nov 24, 2026
2 checks passed
@mstijak
mstijak deleted the feat/overlay-before-dismiss branch November 24, 2026 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant